This folder contains the codes to replicate the results in:

"International trade and labor reallocation: misclassification errors, mobility, and switching costs"
by Maximiliano Dvorkin (2025)
Forthcoming at the Review of Economic and Statistics

The codes run in a Linux cluster using Matlab and Stata. To schedule a run of the code in the cluster, I use SLRUM scheduler.

To replicate follow this steps:
1) To get Tables 1 and 2, Figures 1 and 2, and the point estimates in Tables 3, 4, and 5, go into the folder main and schedule
   a run of the files using "model.srun". 
   Alternatively, you can obtain results without the scheduler by running files in the following order:
   a) go into main/PSID and run Main.do. Then, 			
   b) go into main/CPS and run Main.do. Then, 			
   c) go into main/matlab and run Main_matlab.do. 

2) To get standard errors and the results in Tables 3, 4, and 5 properly formatted, go into into the folder bootstrap and
  a) run the batch file runboot.sh. This will go into each of the sample folders and create a random sample of the datasets with replacement.
  b) after, schedule a run of the file results.srun or alternatively, run the file boot.do in Stata.

3) Generate properly formated Tables by going into the folder Tables_Figures and schedule a run of tables.srun. 
   Alternatively, run main_tables.do in Stata.



Data:
I use PSID and CPS data. To obtain the data you need the following:
 --CPS: go to IPUMS-CPS (https://cps.ipums.org/cps/)
   Generate a data extract from that institution
   The files correspond to the CPS monthly files 
   the samples selected are PUMS-CPS, January 1976 to IPUMS-CPS, December 2019 
   the variables selected are:
		// H 	YEAR 	Survey year
		// H 	SERIAL 	Household serial number
		// H 	MONTH 	Month
		// H 	HWTFINL 	Household weight, Basic Monthly
		// H 	CPSID 	CPSID, household record
		// H 	ASECFLAG 	Flag for ASEC
		// H 	MISH 	Month in sample, household level
		// P 	PERNUM 	Person number in sample unit
		// P 	WTFINL 	Final Basic Weight
		// P 	CPSIDP 	CPSID, person record
		// P 	RELATE 	Relationship to household head
		// P 	AGE 	Age
		// P 	SEX 	Sex
		// P 	RACE 	Race
		// P 	MARST 	Marital status
		// P 	POPSTAT 	Adult civilian, armed forces, or child
		// P 	EMPSTAT 	Employment status
		// P 	LABFORCE 	Labor force status
		// P 	OCC 	Occupation
		// P 	OCC2010 	Occupation, 2010 basis
		// P 	OCC1990 	Occupation, 1990 basis
		// P 	IND1990 	Industry, 1990 basis
		// P 	IND 	Industry
		// P 	CLASSWKR 	Class of worker
		// P 	UHRSWORKT 	Hours usually worked per week at all jobs
		// P 	UHRSWORK1 	Hours usually worked per week at main job
		// P 	AHRSWORKT 	Hours worked last week
		// P 	AHRSWORK1 	Hours worked last week, main job
		// P 	WHYUNEMP 	Reason for unemployment
		// P 	WKSTAT 	Full or part time status
		// P 	EMPSAME 	Still working for same employer
		// P 	ACTSAME 	Still have the same work activities
		// P 	EDUC 	Educational attainment recode
		// P 	LNKFW1YWT 	Longitudinal weight for two adjacent years
		// P 	HOURWAGE 	Hourly wage
		// P 	PAIDHOUR 	Paid by the hour
		// P 	EARNWEEK 	Weekly earnings
		// P 	UHRSWORKORG 	Usual hours worked per week, outgoing rotation groups
		// P 	WKSWORKORG 	Weeks worked per year, outgoing rotation groups	

Save this file in the folder CPS/inputs

PSID:
The PSID variables and sample I use for this project can be downloaded from 
https://www.openicpsr.org/openicpsr/project/215481/version/V1/view

This is a repository that follows PSID guidelines on distributing PSID data for research and replication purposes.
Save this file in the folder PSID/inputs



